package org.ljy.rabbitextensionsdemo.listener;



import org.ljy.rabbitextensionsdemo.constant.Constant;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class DlListener {

    //监听正常队列，模拟拒绝消息
    //@RabbitListener(queues = Constant.NORMAL_QUEUE)
    public void normalListener() {
        System.out.println();
    }

    //监听死信队列
    @RabbitListener(queues = Constant.DL_QUEUE)
    public void dlxListener(Message message) {
        System.out.println("消费时间: "+new Date() +",死信队列："+ new String(message.getBody()));
    }

}
